//
//  WMFeedBackViewController.swift
//  deWaterMarkingProject
//
//  Created by admin on 2025/9/9.
//

import UIKit

class WMFeedBackViewController: WMBaseViewController {

    
    @IBOutlet weak var feedTxtView: UITextView!
    @IBOutlet weak var placeHolderLabel: UILabel!
    
    override func viewDidLoad() {
        super.viewDidLoad()
        // 设置导航栏标题
        customNavBar.setTitle("问题反馈")
        // 添加右侧按钮
        customNavBar.addRightButton(title: "反馈", tintColor:UIColor(valueRGB: UInt(OEMInfo.themeHex), alpha: 1.0), target: self, action: #selector(rightButtonClicked))
    }
    
    @objc private func rightButtonClicked() {
        self.requestFeedback()
    }

    func requestFeedback() {
        self.view.endEditing(true)
        if feedTxtView.text.isEmpty {
            showTips("请输入你要反馈的内容")
            return
        }
        WMAgentApi.shared.requestApi(ApiEnum.feedback(feedTxtView.text)) { res in
            let message = res["message"]
            KBToast.show(message as? String ?? "")
            let code: String = res["code"] as! String
            if (code == "200" || code == "0"){
                Async.main(after: 0.5) { [weak self] in
                    self?.navigationController?.popViewController(animated: true)
                }
            }
        }
       
    }

}

extension WMFeedBackViewController: UITextViewDelegate {
    func textViewDidChange(_ textView: UITextView) {
        placeHolderLabel.isHidden = !textView.text.isEmpty
    }
}
